Sensitivity Analysis¶

In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib import collections
import seaborn as sns
import os
from pathlib import Path
import glob
import re
from cycler import cycler
import itertools

import fiona
import geopandas as gp
from shapely.geometry import LineString, Point, Polygon

%matplotlib inline

sns.color_palette()

sns.set_style("white", {"xtick.direction": "in","ytick.direction": "in"})
plt.rcParams['xtick.bottom'] = True
plt.rcParams['ytick.left'] = True
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=plt.cm.Set2.colors[:6]) 
my_tiel = (0.4, 0.7607843137254902, 0.6470588235294118) # Recycling
my_orange = (0.9882352941176471, 0.5529411764705883, 0.3843137254901961) # Manufacturing
my_purple = (0.5529411764705883, 0.6274509803921569, 0.796078431372549) # 40209
my_pink = (0.9058823529411765, 0.5411764705882353, 0.7647058823529411) #NAICS

Setup all file scenarios¶

The files I am going to load are the ones showed in the table below. This is to know which file correspond to what. I have not added the dates in the file name since they are autogenerated and it is a sanity check for me, but in reality the dates (numbers in front of the file name scenario) don't matter. scenarios_info.png scenarios_info_cap.png

In [28]:
cwd = os.getcwd()
In [29]:
facility_label = ['Manufacturing', 'Recycling', 'Manufacturing_cap', 'Recycling_cap']
location_label = ['NAICS', '40209']
factor_label_rec = ['05', '1', '2', '5', '10']
factor_label_man = ['0001','05', '1', '2'] # 0 is 0,5
In [30]:
files_list = []
for fac in facility_label:
    for loc in location_label:
        if fac.startswith('Manufacturing'):
            for fac_man in factor_label_man:
                files_list.append(fac+'_'+loc+'_'+fac_man)
        else:
            for fac_rec in factor_label_rec:
                files_list.append(fac+'_'+loc+'_'+fac_rec) 
In [31]:
files_list.remove('Manufacturing_cap_NAICS_0001')
files_list.remove('Manufacturing_cap_40209_0001')

Group the files into smaller bins for easier handling¶

In [32]:
recycling_files = [x for x in files_list if x.startswith('Recycling')]
recycling_files_cap = [x for x in recycling_files if "cap" in x]
recycling_files_cost = [x for x in recycling_files if "cap" not in x]
In [33]:
manufacturing_files = [x for x in files_list if x.startswith('Manufacturing')]
manufacturing_files_cap = [x for x in manufacturing_files if "cap" in x]
manufacturing_files_cost = [x for x in manufacturing_files if "cap" not in x]
In [34]:
manufacturing_files_cap
Out[34]:
['Manufacturing_cap_NAICS_05',
 'Manufacturing_cap_NAICS_1',
 'Manufacturing_cap_NAICS_2',
 'Manufacturing_cap_40209_05',
 'Manufacturing_cap_40209_1',
 'Manufacturing_cap_40209_2']

Dictionary to change year number to actual years¶

In [35]:
year_list = list(range(2025, 2051, 1))
number_year = list(range(1, 27, 1))
years_dict = dict(zip(number_year,year_list))

Load plant files¶

Recycling cost¶
In [36]:
for files in recycling_files_cost:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'plants.csv'))[0]
    globals()['%s_plants' % (files)] = pd.read_csv(testfile_path) 
    globals()['%s_plants' % (files)] = globals()['%s_plants' % (files)].replace({"year": years_dict})
    print('{}: {} locations'.format(files, len(globals()['%s_plants' % (files)]['location name'].unique())))
Recycling_NAICS_05: 81 locations
Recycling_NAICS_1: 81 locations
Recycling_NAICS_2: 81 locations
Recycling_NAICS_5: 81 locations
Recycling_NAICS_10: 81 locations
Recycling_40209_05: 87 locations
Recycling_40209_1: 81 locations
Recycling_40209_2: 81 locations
Recycling_40209_5: 81 locations
Recycling_40209_10: 81 locations

Some of the manufacturing files have no solution, so we remove them:

Manufacturing cost¶
In [37]:
manufacturing_files_cost
Out[37]:
['Manufacturing_NAICS_0001',
 'Manufacturing_NAICS_05',
 'Manufacturing_NAICS_1',
 'Manufacturing_NAICS_2',
 'Manufacturing_40209_0001',
 'Manufacturing_40209_05',
 'Manufacturing_40209_1',
 'Manufacturing_40209_2']
In [38]:
for files in manufacturing_files_cost:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'plants.csv'))[0]
    globals()['%s_plants' % (files)] = pd.read_csv(testfile_path) 
    globals()['%s_plants' % (files)] = globals()['%s_plants' % (files)].replace({"year": years_dict})
    print('{}: {} locations'.format(files, len(globals()['%s_plants' % (files)]['location name'].unique())))
Manufacturing_NAICS_0001: 151 locations
Manufacturing_NAICS_05: 62 locations
Manufacturing_NAICS_1: 62 locations
Manufacturing_NAICS_2: 62 locations
Manufacturing_40209_0001: 143 locations
Manufacturing_40209_05: 62 locations
Manufacturing_40209_1: 62 locations
Manufacturing_40209_2: 62 locations
Recycling capacity¶
In [39]:
for files in recycling_files_cap:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'plants.csv'))[0]
    globals()['%s_plants' % (files)] = pd.read_csv(testfile_path)
    globals()['%s_plants' % (files)] = globals()['%s_plants' % (files)].replace({"year": years_dict})
    print('{}: {} locations'.format(files, len(globals()['%s_plants' % (files)]['location name'].unique())))    
Recycling_cap_NAICS_05: 161 locations
Recycling_cap_NAICS_1: 81 locations
Recycling_cap_NAICS_2: 41 locations
Recycling_cap_NAICS_5: 17 locations
Recycling_cap_NAICS_10: 9 locations
Recycling_cap_40209_05: 161 locations
Recycling_cap_40209_1: 81 locations
Recycling_cap_40209_2: 43 locations
Recycling_cap_40209_5: 17 locations
Recycling_cap_40209_10: 10 locations
Manufacturing capacity¶
In [40]:
for files in manufacturing_files_cap:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'plants.csv'))[0]
    globals()['%s_plants' % (files)] = pd.read_csv(testfile_path)
    globals()['%s_plants' % (files)] = globals()['%s_plants' % (files)].replace({"year": years_dict})
    print('{}: {} locations'.format(files, len(globals()['%s_plants' % (files)]['location name'].unique())))    
Manufacturing_cap_NAICS_05: 124 locations
Manufacturing_cap_NAICS_1: 62 locations
Manufacturing_cap_NAICS_2: 31 locations
Manufacturing_cap_40209_05: 124 locations
Manufacturing_cap_40209_1: 62 locations
Manufacturing_cap_40209_2: 31 locations

Selected locations plot¶

In [41]:
rec_cap_locs_data = [['Capacity', 'Recycling', 'NAICS', 0.5, 161], 
                     ['Capacity', 'Recycling','NAICS',1, 81], 
                     ['Capacity', 'Recycling','NAICS',2, 41],
                     ['Capacity', 'Recycling','NAICS',5, 17],
                     ['Capacity', 'Recycling','NAICS',10, 9],
                     ['Capacity', 'Recycling', '40209', 0.5, 161], 
                     ['Capacity', 'Recycling','40209',1, 81], 
                     ['Capacity', 'Recycling','40209',2, 41],
                     ['Capacity', 'Recycling','40209',5, 17],
                     ['Capacity', 'Recycling','40209',10, 10],
                     ['Cost', 'Recycling', 'NAICS',0.5, 81], 
                     ['Cost', 'Recycling','NAICS',1, 81], 
                     ['Cost', 'Recycling','NAICS',2, 81],
                     ['Cost', 'Recycling','NAICS',5, 81],
                     ['Cost', 'Recycling','NAICS',10, 81],
                     ['Cost', 'Recycling', '40209',0.5, 81], 
                     ['Cost', 'Recycling','40209',1, 81], 
                     ['Cost', 'Recycling','40209',2, 81],
                     ['Cost', 'Recycling','40209',5, 81],
                     ['Cost', 'Recycling','40209',10, 81],
                     ['Capacity', 'Manufacturing', 'NAICS',0.5, 124],
                     ['Capacity', 'Manufacturing', 'NAICS',1, 62],
                     ['Capacity', 'Manufacturing', 'NAICS',2, 31],
                     ['Capacity', 'Manufacturing', '40209', 0.5, 124],
                     ['Capacity', 'Manufacturing', '40209', 1, 62],
                     ['Capacity', 'Manufacturing', '40209', 2, 31],
                     ['Cost', 'Manufacturing', 'NAICS',0.001, 151],
                     ['Cost', 'Manufacturing', 'NAICS',0.5, 62],
                     ['Cost', 'Manufacturing', 'NAICS',1, 62],
                     ['Cost', 'Manufacturing', 'NAICS',2, 62],
                     ['Cost', 'Manufacturing', '40209',0.001, 143],
                     ['Cost', 'Manufacturing', '40209',0.5, 62],
                     ['Cost', 'Manufacturing', '40209',1, 62],
                     ['Cost', 'Manufacturing', '40209',2, 62]]

rec_cap_locs_data_df = pd.DataFrame(rec_cap_locs_data, columns=['Analysis', 'Facility', 'Location group','Factor', 'Selected locations'])

Recycling¶

In [49]:
factors_rec = [0.5, 1, 2, 5, 10]
In [50]:
figure = sns.lineplot(x='Factor', y='Selected locations', data=rec_cap_locs_data_df.loc[rec_cap_locs_data_df['Facility'] == 'Recycling'], marker='o', style="Analysis", color=my_tiel)
figure.legend(frameon=False)
figure.set(title='Recycling', ylim = (0, 175))
plt.xticks(factors_rec, labels = factors_rec)
plt.savefig(os.path.join(cwd, f"recycling_selected.png"), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, f"recycling_selected.pdf"), dpi=300);

Manufacturing¶

In [51]:
factors_man = [0.001, 0.5, 1, 2]
In [52]:
figure = sns.lineplot(x='Factor', y='Selected locations', data=rec_cap_locs_data_df.loc[rec_cap_locs_data_df['Facility'] == 'Manufacturing'], marker='o', style="Analysis", color=my_orange)
figure.legend(frameon=False)
figure.set(title='Manufacturing', ylim = (0, 175))
plt.xticks(factors_man, labels = factors_man)
plt.savefig(os.path.join(cwd, f"manufacturing_selected.png"), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, f"manufacturing_selected.pdf"), dpi=300);

Grid plot¶

Recycling Capacity Utilization Factor¶

In [53]:
for files in recycling_files_cap:
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "utilization factor (%)", color=my_tiel)
    grid.map(plt.fill_between, 'year', 'utilization factor (%)',color= my_tiel, alpha= 0.2)
    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    #grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}", y=1.2)


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_uf.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_uf.pdf"), dpi=300);

Recycling Capacity Total Cost¶

In [54]:
for files in recycling_files_cap:
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "total cost ($)", color=my_tiel)
    grid.map(plt.fill_between, 'year', 'total cost ($)',color= my_tiel, alpha= 0.2)
    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_totcost.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_totcost.pdf"), dpi=300);
In [ ]:
 

Recycling Cost Utilization Factor¶

In [55]:
for files in recycling_files_cost:
# Initialize a grid of plots with an Axes for each walk
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "utilization factor (%)", color=my_tiel)
    grid.map(plt.fill_between, "year", 'utilization factor (%)',color= my_tiel, alpha= 0.2)
    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_uf.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_uf.pdf"), dpi=300);
In [ ]:
 

Recycling Cost Total Cost¶

In [56]:
for files in recycling_files_cost:
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "total cost ($)", color=my_tiel)
    grid.map(plt.fill_between, 'year', 'total cost ($)',color= my_tiel, alpha= 0.2)
    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_totcost.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_totcost.pdf"), dpi=300);
In [ ]:
 

Manufacturing Capacity Utilization Factor¶

In [57]:
for files in manufacturing_files_cap:
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "utilization factor (%)", color=my_orange)
    grid.map(plt.fill_between, 'year', 'utilization factor (%)',color= my_orange, alpha= 0.2)
    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_uf.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_uf.pdf"), dpi=300);

Manufacturing Capacity Total Cost¶

In [58]:
for files in manufacturing_files_cap:
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "total cost ($)", color=my_orange)
    grid.map(plt.fill_between, 'year', 'total cost ($)',color= my_orange, alpha= 0.2)

    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_totcost.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cap_totcost.pdf"), dpi=300);
In [ ]:
 

Manufacturing Cost Utilization Factor¶

In [59]:
for files in manufacturing_files_cost:
# Initialize a grid of plots with an Axes for each walk
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "utilization factor (%)", color=my_orange)
    grid.map(plt.fill_between, 'year', 'utilization factor (%)',color= my_orange, alpha= 0.2)

    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_uf.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_uf.pdf"), dpi=300);
In [ ]:
 

Manufacturing Cost Total Cost¶

In [60]:
for files in manufacturing_files_cost:
# Initialize a grid of plots with an Axes for each walk
    grid = sns.FacetGrid(globals()['%s_plants' % (files)], col="location name",
                         col_wrap=9, height=1.5)

    # Draw a horizontal line to show the starting point
    grid.refline(y=0, linestyle=":")


    grid.map(plt.plot, "year", "total cost ($)", color=my_orange)
    grid.map(plt.fill_between, 'year', 'total cost ($)',color= my_orange, alpha= 0.2)

    # Adjust the tick positions, labels and 
    #sns.set(font_scale=0.1)
    grid.set_titles(row_template = '{row_name}', col_template = '{col_name}', size=5)

    grid.fig.tight_layout(w_pad=1)
    grid.fig.subplots_adjust(top=0.9)
    grid.fig.suptitle(f"{files}")


    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_totcost.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, f"grid_26_years/grid_{files}_cost_totcost.pdf"));
In [ ]:
 
In [ ]:
 

Map plots¶

USA map source2.

In [61]:
import fiona
import geopandas as gp
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib import collections
import matplotlib.pyplot as plt
from shapely.geometry import LineString, Point, Polygon

%matplotlib inline

Load transportation files¶

Recycling cost¶
In [62]:
for files in recycling_files_cost:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'transportation.csv'))[0]
    globals()['%s_transportation' % (files)] = pd.read_csv(testfile_path) 
    globals()['%s_transportation' % (files)] = globals()['%s_transportation' % (files)].replace({"year": years_dict})
Recycling capacity¶
In [63]:
for files in recycling_files_cap:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'transportation.csv'))[0]
    globals()['%s_transportation' % (files)] = pd.read_csv(testfile_path) 
    globals()['%s_transportation' % (files)] = globals()['%s_transportation' % (files)].replace({"year": years_dict})
Manufacturing cost¶
In [64]:
for files in manufacturing_files_cost:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'transportation.csv'))[0]
    globals()['%s_transportation' % (files)] = pd.read_csv(testfile_path) 
    globals()['%s_transportation' % (files)] = globals()['%s_transportation' % (files)].replace({"year": years_dict})
Manufacturing capacity¶
In [65]:
for files in manufacturing_files_cap:
    testfile_path = glob.glob(os.path.join(cwd, "scenarios_26_years", files, 'transportation.csv'))[0]
    globals()['%s_transportation' % (files)] = pd.read_csv(testfile_path) 
    globals()['%s_transportation' % (files)] = globals()['%s_transportation' % (files)].replace({"year": years_dict})

Recycling cost maps¶

In [66]:
my_tiel = (0.4, 0.7607843137254902, 0.6470588235294118)
In [67]:
for files in recycling_files_cost:    
    # Plot base map
    world = gp.read_file(os.path.join(cwd, f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
    world = world.to_crs("EPSG:4326")
    ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
    ax.set_ylim([23, 50])
    ax.set_xlim([-128, -65])
    plt.axis('off')
    ax.set(title=f'{files}')
    # Draw transportation lines
    data = globals()['%s_transportation' % (files)]
    lines = [
        [
            (
                row["source longitude (deg)"],
                row["source latitude (deg)"],
            ),
            (
                row["destination longitude (deg)"],
                row["destination latitude (deg)"],
            ),
        ]
        for (index, row) in data.iterrows()
    ]
    ax.add_collection(
        collections.LineCollection(
            lines,
            linewidths=0.005,
            zorder=1,
            alpha=1,
            color=my_tiel,
        )
    )

    # Draw source points
    points = gp.points_from_xy(
        data["source longitude (deg)"],
        data["source latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, marker='D',color=my_tiel, markersize=10, edgecolor='white', linewidth=0.5)

    # Draw destination points
    points = gp.points_from_xy(
        data["destination longitude (deg)"],
        data["destination latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, markersize=60, color=my_tiel , edgecolor='white', linewidth=0.5)

    legend_elements = [Line2D([0], [0], color=my_tiel, lw=1, label='Transport route'),
                   Line2D([0], [0], marker='D', color=my_tiel, label='Collection center', markersize=3, linestyle='None'),
                   Line2D([0], [0], marker='o', color=my_tiel, label='Recycling center', markersize=10, linestyle='None')]
    ax.legend(handles=legend_elements, frameon=False, bbox_to_anchor=(0.35, 0.25))   

    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cost.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cost.pdf"), dpi=300);

Recycling capacity maps¶

In [68]:
for files in recycling_files_cap:    
    # Plot base map
    world = gp.read_file(os.path.join(cwd, f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
    world = world.to_crs("EPSG:4326")
    ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
    ax.set_ylim([23, 50])
    ax.set_xlim([-128, -65])
    plt.axis('off')
    ax.set(title=f'{files}')
    # Draw transportation lines
    data = globals()['%s_transportation' % (files)]
    lines = [
        [
            (
                row["source longitude (deg)"],
                row["source latitude (deg)"],
            ),
            (
                row["destination longitude (deg)"],
                row["destination latitude (deg)"],
            ),
        ]
        for (index, row) in data.iterrows()
    ]
    ax.add_collection(
        collections.LineCollection(
            lines,
            linewidths=0.005,
            zorder=1,
            alpha=1,
            color=my_tiel,
        )
    )

    # Draw source points
    points = gp.points_from_xy(
        data["source longitude (deg)"],
        data["source latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, marker='D',color=my_tiel, markersize=10, edgecolor='white', linewidth=0.5)

    # Draw destination points
    points = gp.points_from_xy(
        data["destination longitude (deg)"],
        data["destination latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, markersize=60, color=my_tiel, edgecolor='white', linewidth=0.5)

    legend_elements = [Line2D([0], [0], color=my_tiel, lw=1, label='Transport route'),
                   Line2D([0], [0], marker='D', color=my_tiel, label='Collection center', markersize=3, linestyle='None'),
                   Line2D([0], [0], marker='o', color=my_tiel, label='Recycling center', markersize=10, linestyle='None')]
    ax.legend(handles=legend_elements, frameon=False, bbox_to_anchor=(0.35, 0.25))    
    
    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cap.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cap.pdf"), dpi=300);

Manufacturing cost maps¶

In [122]:
for files in manufacturing_files_cost:    
    # Plot base map
    world = gp.read_file(os.path.join(cwd, 'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
    world = world.to_crs("EPSG:4326")
    ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
    ax.set_ylim([23, 50])
    ax.set_xlim([-128, -65])
    plt.axis('off')
    ax.set(title=f'{files}')
    # Draw transportation lines
    data = globals()['%s_transportation' % (files)]
    lines = [
        [
            (
                row["source longitude (deg)"],
                row["source latitude (deg)"],
            ),
            (
                row["destination longitude (deg)"],
                row["destination latitude (deg)"],
            ),
        ]
        for (index, row) in data.iterrows()
    ]
    ax.add_collection(
        collections.LineCollection(
            lines,
            linewidths=0.005,
            zorder=1,
            #alpha=0.3,
            color=my_orange,
        )
    )

    # Draw source points
    points = gp.points_from_xy(
        data["source longitude (deg)"],
        data["source latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, marker='D',color=my_orange, markersize=10, edgecolor='white', linewidth=0.5)

    # Draw destination points
    points = gp.points_from_xy(
        data["destination longitude (deg)"],
        data["destination latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax,markersize=60, color=my_orange, edgecolor='white', linewidth=0.5)
    
    legend_elements = [Line2D([0], [0], color=my_orange, lw=1, label='Transport route'),
                   Line2D([0], [0], marker='D', color=my_orange, label='Collection center', markersize=3, linestyle='None'),
                   Line2D([0], [0], marker='o', color=my_orange, label='Recycling center', markersize=10, linestyle='None')]
    ax.legend(handles=legend_elements, frameon=False, bbox_to_anchor=(0.35, 0.25))

    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cost.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cost.pdf"), dpi=300);

Manufacturing capacity maps¶

In [121]:
for files in manufacturing_files_cap:    
    # Plot base map
    world = gp.read_file(os.path.join(f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
    world = world.to_crs("EPSG:4326")
    ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
    ax.set_ylim([23, 50])
    ax.set_xlim([-128, -65])
    plt.axis('off')
    ax.set(title=f'{files}')
    # Draw transportation lines
    data = globals()['%s_transportation' % (files)]
    lines = [
        [
            (
                row["source longitude (deg)"],
                row["source latitude (deg)"],
            ),
            (
                row["destination longitude (deg)"],
                row["destination latitude (deg)"],
            ),
        ]
        for (index, row) in data.iterrows()
    ]
    ax.add_collection(
        collections.LineCollection(
            lines,
            linewidths=0.005,
            zorder=1,
            #alpha=0.3,
            color=my_orange,
        )
    )

    # Draw source points
    points = gp.points_from_xy(
        data["source longitude (deg)"],
        data["source latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, marker='D',color=my_orange, markersize=10, edgecolor='white', linewidth=0.5)

    # Draw destination points
    points = gp.points_from_xy(
        data["destination longitude (deg)"],
        data["destination latitude (deg)"],
    )
    gp.GeoDataFrame(data, geometry=points).plot(ax=ax, markersize=60, color=my_orange, edgecolor='white', linewidth=0.5)
    
    legend_elements = [Line2D([0], [0], color=my_orange, lw=1, label='Transport route'),
                   Line2D([0], [0], marker='D', color=my_orange, label='Collection center', markersize=3, linestyle='None'),
                   Line2D([0], [0], marker='o', color=my_orange, label='Recycling center', markersize=10, linestyle='None')]
    ax.legend(handles=legend_elements, frameon=False, bbox_to_anchor=(0.35, 0.25))
    
    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cap.png"), transparent=True, dpi=300);
    plt.savefig(os.path.join(cwd, "maps_26_years",f"map_{files}_cap.pdf"), dpi=300);
    

Overlapping locations¶

In [71]:
def intersection(lst1, lst2):
    lst3 = [value for value in lst1 if value in lst2]
    return lst3

Overlap between manufacturing and recycling¶

In [72]:
print('40209 overlap x0.5 cost:', len(intersection(Recycling_40209_05_plants['location name'].unique(), 
                                              Manufacturing_40209_05_plants['location name'].unique())))
print('40209 overlap x1 cost:', len(intersection(Recycling_40209_1_plants['location name'].unique(), 
                                              Manufacturing_40209_1_plants['location name'].unique())))
print('40209 overlap x2 cost:', len(intersection(Recycling_40209_2_plants['location name'].unique(), 
                                              Manufacturing_40209_2_plants['location name'].unique())))
print('NAICS overlap x0.5 cost:', len(intersection(Recycling_NAICS_05_plants['location name'].unique(), 
                                              Manufacturing_NAICS_05_plants['location name'].unique())))
print('NAICS overlap x1 cost:', len(intersection(Recycling_NAICS_1_plants['location name'].unique(), 
                                              Manufacturing_NAICS_1_plants['location name'].unique())))
print('NAICS overlap x2 cost:', len(intersection(Recycling_NAICS_2_plants['location name'].unique(), 
                                              Manufacturing_NAICS_2_plants['location name'].unique())))
print('40209 overlap x1 capacity:', len(intersection(Recycling_cap_40209_1_plants['location name'].unique(), 
                                              Manufacturing_cap_40209_1_plants['location name'].unique())))
print('40209 overlap x2 capacity:', len(intersection(Recycling_cap_40209_2_plants['location name'].unique(), 
                                              Manufacturing_cap_40209_2_plants['location name'].unique())))
print('NAICS overlap x1 capacity:', len(intersection(Recycling_cap_NAICS_1_plants['location name'].unique(), 
                                              Manufacturing_cap_NAICS_1_plants['location name'].unique()))),
print('NAICS overlap x2 capacity:', len(intersection(Recycling_cap_NAICS_2_plants['location name'].unique(), 
                                              Manufacturing_cap_NAICS_2_plants['location name'].unique())))
40209 overlap x0.5 cost: 55
40209 overlap x1 cost: 60
40209 overlap x2 cost: 62
NAICS overlap x0.5 cost: 46
NAICS overlap x1 cost: 54
NAICS overlap x2 cost: 60
40209 overlap x1 capacity: 60
40209 overlap x2 capacity: 25
NAICS overlap x1 capacity: 54
NAICS overlap x2 capacity: 25

Common locations to select specific cities¶

In [73]:
Recycling_40209_1_plants.keys()
Out[73]:
Index(['plant type', 'location name', 'year', 'latitude (deg)',
       'longitude (deg)', 'capacity (tonne)', 'amount processed (tonne)',
       'amount received (tonne)', 'amount in storage (tonne)',
       'utilization factor (%)', 'energy (GJ)', 'opening cost ($)',
       'expansion cost ($)', 'fixed operating cost ($)',
       'variable operating cost ($)', 'storage cost ($)', 'total cost ($)'],
      dtype='object')

40209 common locations¶

In [74]:
common_rec_40209 = intersection(   # Cost analysis
                       intersection(
                           intersection(
                               intersection(
                                   Recycling_40209_1_plants['location name'].unique(), 
                                   Recycling_40209_05_plants['location name'].unique()), 
                                   Recycling_40209_2_plants['location name'].unique()),
                                   Recycling_40209_5_plants['location name'].unique()),
                                   Recycling_40209_10_plants['location name'].unique())
len(common_rec_40209)
Out[74]:
59
In [75]:
common_rec_cap_40209 = intersection(  # Capacity analysis
                           intersection(
                               intersection(
                                   intersection(
                                       Recycling_cap_40209_1_plants['location name'].unique(), 
                                       Recycling_cap_40209_05_plants['location name'].unique()), 
                                       Recycling_cap_40209_2_plants['location name'].unique()),
                                       Recycling_cap_40209_5_plants['location name'].unique()),
                                       Recycling_cap_40209_10_plants['location name'].unique())
len(common_rec_cap_40209)
Out[75]:
9
In [76]:
Recycling_cap_40209_05_plants['location name']
Out[76]:
0          Glen Lyn, Virginia
1          Glen Lyn, Virginia
2          Glen Lyn, Virginia
3          Glen Lyn, Virginia
4          Glen Lyn, Virginia
                ...          
4181    J C Weadock, Michigan
4182    J C Weadock, Michigan
4183    J C Weadock, Michigan
4184    J C Weadock, Michigan
4185    J C Weadock, Michigan
Name: location name, Length: 4186, dtype: object
In [77]:
common_man_40209 = intersection(   # Cost analysis
                        intersection(
                            intersection(
                                Manufacturing_40209_0001_plants['location name'].unique(), 
                                Manufacturing_40209_05_plants['location name'].unique()), 
                                Manufacturing_40209_1_plants['location name'].unique()),
                                Manufacturing_40209_2_plants['location name'].unique())
len(common_man_40209)
Out[77]:
48
In [78]:
common_man_cap_40209 = intersection(   # Capacity analysis
                                Manufacturing_cap_40209_1_plants['location name'].unique(),
                                Manufacturing_cap_40209_2_plants['location name'].unique())
len(common_man_cap_40209)
Out[78]:
31
In [79]:
common_40209 = intersection(
                    intersection(
                        intersection(
                            common_rec_40209, common_rec_cap_40209),
                            common_man_40209),
                            common_man_cap_40209)
len(common_40209)
Out[79]:
6
In [80]:
common_40209
Out[80]:
['Cholla, Arizona',
 'R D Morrow, Mississippi',
 'Northeastern, Oklahoma',
 'Crystal River, Florida',
 'Potomac River, Virginia',
 'Navajo, Arizona']

I choose three locations:

- 'Navajo, Arizona'
- 'Clinch River, Virginia'
- 'R D Morrow, Mississippi'
In [81]:
common_40209_selected = ['Navajo, Arizona', 'Clinch River, Virginia', 'R D Morrow, Mississippi']

NAICS common locations¶

In [82]:
common_rec_NAICS = intersection(  # Cost analysis
                       intersection(
                           intersection(
                               intersection(
                                   Recycling_NAICS_1_plants['location name'].unique(), 
                                   Recycling_NAICS_05_plants['location name'].unique()), 
                                   Recycling_NAICS_2_plants['location name'].unique()),
                                   Recycling_NAICS_5_plants['location name'].unique()),
                                   Recycling_NAICS_10_plants['location name'].unique())
len(common_rec_NAICS)
Out[82]:
52
In [83]:
common_rec_cap_NAICS = intersection(  # Capacity analysis
                       intersection(
                           intersection(
                               intersection(
                                   Recycling_cap_NAICS_1_plants['location name'].unique(), 
                                   Recycling_cap_NAICS_05_plants['location name'].unique()), 
                                   Recycling_cap_NAICS_2_plants['location name'].unique()),
                                   Recycling_cap_NAICS_5_plants['location name'].unique()),
                                   Recycling_cap_NAICS_10_plants['location name'].unique())
len(common_rec_cap_NAICS)
Out[83]:
9
In [84]:
common_man_NAICS = intersection(  # Cost analysis
                        intersection(
                            intersection(
                                Manufacturing_NAICS_0001_plants['location name'].unique(), 
                                Manufacturing_NAICS_05_plants['location name'].unique()), 
                                Manufacturing_NAICS_1_plants['location name'].unique()),
                                Manufacturing_NAICS_2_plants['location name'].unique())
len(common_man_NAICS)
Out[84]:
48
In [85]:
common_man_cap_NAICS = intersection(  # Capacity analysis 
                                Manufacturing_cap_NAICS_1_plants['location name'].unique(),
                                Manufacturing_cap_NAICS_2_plants['location name'].unique())
len(common_man_cap_NAICS)
Out[85]:
31
In [86]:
common_NAICS = intersection(
                    intersection(
                        intersection(
                            common_rec_NAICS, common_rec_cap_NAICS),
                            common_man_NAICS),
                            common_man_cap_NAICS)
len(common_NAICS)
Out[86]:
5
In [87]:
common_NAICS
Out[87]:
['Baldor Electric Co., AR',
 'Standard Enterprises, Inc., VA',
 'MMC Materials, Inc., MS',
 'Boye Knives, AZ',
 'Bain Mfg. Co., Inc., MS']

The corresponding counties here are:

- Clarksville, Arizona
- Columbia, Missisipi
- Lake Havasu City, Arizona
- Charlottesville, Virginia
- Phoenix, Arizona
- Madison County, Missisipi
- Dolan Springs, Arizona
- Portsmouth, Virginia
- Grenada, Missisipi

Selected:

- Dolan Springs, Arizona or 'Boye Knives, AZ', close to Hualapai reservation.
- Grenada, Missisipi or 'Bain Mfg. Co., Inc., MS': Close to a highway, 
- Charlottesville, Virginia or 'Standard Enterprises, Inc.': More remote, 

Recycling plots¶

In [88]:
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=plt.cm.Set2.colors[:6])
In [89]:
years_list = np.arange(2025, 2051, 5)
40209 Recycling plants - Cost Sensitivity Analysis¶
In [90]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("40209 Recycling plants - Cost Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in recycling_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Navajo, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        
for files in recycling_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[1, 0].set_title('R D Morrow, Mississippi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        
for files in recycling_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[2, 0].set_title('Clinch River, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)", ylim = (0, 105))
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

        
for files in recycling_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Navajo, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 125000000))
for files in recycling_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.2, 0.75), frameon=False)
        axs[1, 1].set_title('R D Morrow, Mississippi')
        axs[1, 1].margins(x=0, y=5)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 125000000))
        
for files in recycling_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[2, 1].set_title('Clinch River, Virginia')
        axs[2, 1].margins(x=0)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 125000000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')  

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)        
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Recycling_40209_cost_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Recycling_40209_cost_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/2293070169.py:41: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/2293070169.py:76: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
40209 Recycling plants - Capacity Sensitivity Analysis¶
In [91]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("40209 Recycling plants - Capacity Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in recycling_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Navajo, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
    
for files in recycling_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[1, 0].set_title('R D Morrow, Mississippi')
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)",ylim = (0, 105))
        
for files in recycling_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[2, 0].set_title('Clinch River, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)", ylim = (0, 105))
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
        
for files in recycling_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Navajo, Arizona')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 26200000))
        
for files in recycling_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.2, 0.75), frameon=False)
        axs[1, 1].set_title('R D Morrow, Mississippi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 26200000))
        
for files in recycling_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[2, 1].set_title('Clinch River, Virginia')
        axs[2, 1].margins(x=0)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 26200000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Recycling_40209_capacity_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Recycling_40209_capacity_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/3209683946.py:39: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/3209683946.py:71: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
NAICS Recycling plants - Cost Sensitivity Analysis¶
In [92]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("NAICS Recycling plants - Cost Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in recycling_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Dolan Springs, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")

for files in recycling_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[1, 0].set_title('Grenada, Missisipi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
# for ax in axs.flat:
#     ax.set(xlabel='Year', ylabel='Utilization factor (%)')
    
for files in recycling_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 0].set_title('Charlottesville, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)")
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
        
for files in recycling_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Dolan Springs, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 125000000))

for files in recycling_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.2, 0.75), frameon=False)
        axs[1, 1].set_title('Grenada, Missisipi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 125000000))
    
for files in recycling_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 1].set_title('Charlottesville, Virginia')
        axs[2, 1].margins(x=0, y=5)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 125000000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)       
fig.savefig(os.path.join(cwd, f"selected_plants_26_years","Recycling_NAICS_cost_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years","Recycling_NAICS_cost_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/2907320501.py:42: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/2907320501.py:78: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
NAICS Recycling plants - Capacity Sensitivity Analysis¶
In [93]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("NAICS Recycling plants - Capacity Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in recycling_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Dolan Springs, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")

for files in recycling_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[1, 0].set_title('Grenada, Missisipi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
# for ax in axs.flat:
#     ax.set(xlabel='Year', ylabel='Utilization factor (%)')
    
for files in recycling_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 0].set_title('Charlottesville, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)")
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
        
for files in recycling_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Dolan Springs, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 26200000))

for files in recycling_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.2, 0.75), frameon=False)
        axs[1, 1].set_title('Grenada, Missisipi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 26200000))
    
for files in recycling_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,2})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 1].set_title('Charlottesville, Virginia')
        axs[2, 1].margins(x=0, y=5)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 26200000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Recycling_NAICS_capacity_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Recycling_NAICS_capacity_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/3529915961.py:42: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/3529915961.py:78: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

Manufacturing plots¶

40209 Manufacturing plants - Cost Sensitivity Analysis¶
In [94]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("40209 Manufacturing plants - Cost Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in manufacturing_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Navajo, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        
for files in manufacturing_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[1, 0].set_title('R D Morrow, Mississippi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        
for files in manufacturing_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[2, 0].set_title('Clinch River, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)", ylim = (0, 105))
        axs[2, 0].set_xticklabels(labels=state['year'], rotation=45, ha='right', rotation_mode='anchor')

        
for files in manufacturing_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Navajo, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)",  ylim = (0, 2190000000))
        axs[0, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
        
for files in manufacturing_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.25, 0.75), frameon=False)
        axs[1, 1].set_title('R D Morrow, Mississippi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)")
        axs[1, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))        
for files in manufacturing_files_cost:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[2, 1].set_title('Clinch River, Virginia')
        axs[2, 1].margins(x=0)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[2, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')  

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)        
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_40209_cost_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_40209_cost_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/4082125229.py:41: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(labels=state['year'], rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/4082125229.py:79: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
40209 Manufacturing plants - Capacity Sensitivity Analysis¶
In [119]:
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=plt.cm.Set2.colors[2:5])
In [120]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("40209 Manufacturing plants - Capacity Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in manufacturing_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Navajo, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        
for files in manufacturing_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[1, 0].set_title('R D Morrow, Mississippi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        
for files in manufacturing_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[2, 0].set_title('Clinch River, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)", ylim = (0, 105))
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

        
for files in manufacturing_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Navajo, Arizona']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Navajo, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)",  ylim = (0, 2190000000))
        axs[0, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
        #axs[0, 1].xaxis.set_ticks(np.arange(2025, 2051))
        
for files in manufacturing_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'R D Morrow, Mississippi']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.25, 0.75), frameon=False)
        axs[1, 1].set_title('R D Morrow, Mississippi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[1, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))        
for files in manufacturing_files_cap:
    if '40209' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Clinch River, Virginia']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[2, 1].set_title('Clinch River, Virginia')
        axs[2, 1].margins(x=0)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[2, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')  

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)        
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_40209_capacity_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_40209_capacity_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/2908762764.py:41: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/2908762764.py:80: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
NAICS Manufacturing plants - Cost Sensitivity Analysis¶
In [97]:
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=plt.cm.Set2.colors[:6])
In [98]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("NAICS Manufacturing plants - Cost Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in manufacturing_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Dolan Springs, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")

for files in manufacturing_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[1, 0].set_title('Grenada, Missisipi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
# for ax in axs.flat:
#     ax.set(xlabel='Year', ylabel='Utilization factor (%)')
    
for files in manufacturing_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 0].set_title('Charlottesville, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)")
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
        
for files in manufacturing_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Dolan Springs, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[0, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))

for files in manufacturing_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.25, 0.75), frameon=False)
        axs[1, 1].set_title('Grenada, Missisipi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[2, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
    
for files in manufacturing_files_cost:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 1].set_title('Charlottesville, Virginia')
        axs[2, 1].margins(x=0, y=5)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[2, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)               
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_NAICS_cost_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_NAICS_cost_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/1183286205.py:42: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/1183286205.py:81: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
NAICS Manufacturing plants - Capacity Sensitivity Analysis¶
In [99]:
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=plt.cm.Set2.colors[2:4])
In [100]:
fig, axs = plt.subplots(3, 2, figsize=(10,10),sharex=True)
fig.tight_layout(pad=1.5)
fig.suptitle("NAICS Manufacturing plants - Capacity Sensitivity Analysis",fontsize=20)
fig.subplots_adjust(top=0.92)

for files in manufacturing_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[0, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 0].set_title('Dolan Springs, Arizona')
        axs[0, 0].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 0].set(xlabel=" ", ylabel="Utilization factor (%)")

for files in manufacturing_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[1, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[1, 0].legend(bbox_to_anchor=(1.1, 0.75), frameon=False)
        axs[1, 0].set_title('Grenada, Missisipi')
        axs[1, 0].margins(x=0)
        axs[1, 0].set(xlabel=" ", ylabel="Utilization factor (%)")
# for ax in axs.flat:
#     ax.set(xlabel='Year', ylabel='Utilization factor (%)')
    
for files in manufacturing_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 0].plot(state['year'], state['utilization factor (%)'], label = fr'{regex}')
        axs[2, 0].fill_between(state['year'], state['utilization factor (%)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 0].set_title('Charlottesville, Virginia')
        axs[2, 0].margins(x=0)
        axs[2, 0].set(xlabel="Year", ylabel="Utilization factor (%)")
        axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
        
for files in manufacturing_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Boye Knives, AZ']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[0, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[0, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[0].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[0, 1].set_title('Dolan Springs, Arizona')
        axs[0, 1].margins(x=0)
        # axs[0].xlabel('Year')
        # axs[0].ylabel('Utilization factor (%)')
        axs[0, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[0, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))

for files in manufacturing_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Bain Mfg. Co., Inc., MS']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[1, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[1, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        axs[1, 1].legend(bbox_to_anchor=(1.2, 0.75), frameon=False)
        axs[1, 1].set_title('Grenada, Missisipi')
        axs[1, 1].margins(x=0)
        axs[1, 1].set(xlabel=" ", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[1, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
    
for files in manufacturing_files_cap:
    if 'NAICS' in files:
        state = globals()['%s_plants' % (files)].loc[globals()['%s_plants' % (files)]['location name'] == 'Standard Enterprises, Inc., VA']
        regex = re.findall('\w+_\w+_(\d{1,4})', files)[0]
        axs[2, 1].plot(state['year'], state['total cost ($)'], label = fr'{regex}')
        axs[2, 1].fill_between(state['year'], state['total cost ($)'], alpha=0.1)
        #axs[2].legend(bbox_to_anchor=(1, 1.05), frameon=False)
        axs[2, 1].set_title('Charlottesville, Virginia')
        axs[2, 1].margins(x=0, y=5)
        axs[2, 1].set(xlabel="Year", ylabel="Total cost ($)", ylim = (0, 2190000000))
        axs[2, 1].yaxis.set_ticks(np.arange(0, 2190000000, 400000000))
        axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')

plt.gcf().subplots_adjust(bottom=0.06, right=0.91, left=0.06)    
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_NAICS_capacity_analysis.png"), dpi=300, transparent=True);
fig.savefig(os.path.join(cwd, f"selected_plants_26_years/Manufacturing_NAICS_capacity_analysis.pdf"), dpi=300);
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/3216271169.py:42: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 0].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
/var/folders/w2/85_h_nyn0mlbxf81x3k9n53xh90n_1/T/ipykernel_99819/3216271169.py:81: UserWarning: FixedFormatter should only be used together with FixedLocator
  axs[2, 1].set_xticklabels(years_list, rotation=45, ha='right', rotation_mode='anchor')
In [101]:
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=plt.cm.Set2.colors[:6])
In [ ]:
 
In [ ]:
 
In [ ]:
 

Candidates maps¶

Find the location files

In [102]:
p = Path(cwd)
In [103]:
p.parent.parent
Out[103]:
PosixPath('/Users/mmendez/Documents/Postdoc/Software_dev/RICE')
In [104]:
locations_files_path = os.path.join(p.parent.parent, '2_data_preparation', 'RELOG_import_data', 'CandidateLocations')
In [105]:
data_40209 = pd.read_csv(os.path.join(locations_files_path, 'cl_40209_retired_plants.csv'))
data_NAICS = pd.read_csv(os.path.join(locations_files_path, 'cl_igate_single_loc_filter_naics.csv'))

40209 Candidate locations¶

In [106]:
world = gp.read_file(os.path.join(cwd, f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
world = world.to_crs("EPSG:4326")
ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
ax.set_ylim([23, 50])
ax.set_xlim([-128, -65])
plt.axis('off')
plt.title('40209 Candidate Locations', fontdict = {'fontsize' : 20})
# Draw destination points
points = gp.points_from_xy(
    data_40209["longitude (deg)"],
    data_40209["latitude (deg)"],
)
gp.GeoDataFrame(data_40209, geometry=points).plot(ax=ax, color=my_purple, markersize=50, alpha=1)

    
plt.savefig(os.path.join(cwd, "maps_26_years",f"map_40209_candidates.png"), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, "maps_26_years",f"map_40209_candidates.pdf"), dpi=300);
In [107]:
world = gp.read_file(os.path.join(cwd, f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
world = world.to_crs("EPSG:4326")
ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
ax.set_ylim([23, 50])
ax.set_xlim([-128, -65])
plt.axis('off')
plt.title('NAICS Candidate Locations', fontdict = {'fontsize' : 20})
# Draw destination points
points = gp.points_from_xy(
    data_NAICS["longitude (deg)"],
    data_NAICS["latitude (deg)"],
)
gp.GeoDataFrame(data_NAICS, geometry=points).plot(ax=ax, color=my_pink, markersize=50, alpha=1)

plt.savefig(os.path.join(cwd, "maps_26_years",f"map_NAICS_candidates.png"), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, "maps_26_years",f"map_NAICS_candidates.pdf"), dpi=300);

Testing plots¶

In [108]:
# Plot base map
world = gp.read_file(os.path.join(cwd, f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
world = world.to_crs("EPSG:4326")
ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
ax.set_ylim([23, 50])
ax.set_xlim([-128, -65])
plt.axis('off')
ax.set(title=f'Recycling_40209_1_transportation')
# Draw transportation lines
data = Recycling_40209_1_transportation
lines = [
    [
        (
            row["source longitude (deg)"],
            row["source latitude (deg)"],
        ),
        (
            row["destination longitude (deg)"],
            row["destination latitude (deg)"],
        ),
    ]
    for (index, row) in data.iterrows()
]
ax.add_collection(
    collections.LineCollection(
        lines,
        linewidths=0.005,
        zorder=1,
        alpha=0.7,
        color=my_orange,
    )
)

# Draw source points
points = gp.points_from_xy(
    data["source longitude (deg)"],
    data["source latitude (deg)"],
)
gp.GeoDataFrame(data, geometry=points).plot(ax=ax, marker='D',color=my_orange, markersize=10, edgecolor='white', linewidth=0.5)

# Draw destination points
points = gp.points_from_xy(
    data["destination longitude (deg)"],
    data["destination latitude (deg)"],
)
gp.GeoDataFrame(data, geometry=points).plot(ax=ax, markersize=60, color=my_orange, edgecolor='white', linewidth=0.5)

legend_elements = [Line2D([0], [0], color='lightsalmon', lw=1, label='Transport route'),
                   Line2D([0], [0], marker='D', color=my_orange, label='Collection center', markersize=3, linestyle='None'),
                   Line2D([0], [0], marker='o', color=my_orange, label='Recycling center', markersize=10, linestyle='None')]
ax.legend(handles=legend_elements, frameon=False, bbox_to_anchor=(0.35, 0.25))
Out[108]:
<matplotlib.legend.Legend at 0x1505d7070>
In [109]:
# Plot base map
world = gp.read_file(os.path.join(cwd, f'resources','USA_States_(Generalized)', 'USA_States_Generalized.shp'))
world = world.to_crs("EPSG:4326")
ax = world.plot(color="0.9", edgecolor="1", figsize=(14, 7))
ax.set_ylim([23, 50])
ax.set_xlim([-128, -65])
plt.axis('off')
ax.set(title=f'Recycling_40209_1_transportation')
# Draw transportation lines
data = Recycling_40209_1_transportation
lines = [
    [
        (
            row["source longitude (deg)"],
            row["source latitude (deg)"],
        ),
        (
            row["destination longitude (deg)"],
            row["destination latitude (deg)"],
        ),
    ]
    for (index, row) in data.iterrows()
]
ax.add_collection(
    collections.LineCollection(
        lines,
        linewidths=0.005,
        zorder=1,
        alpha=0.7,
        color=my_tiel,
    )
)

# Draw source points
points = gp.points_from_xy(
    data["source longitude (deg)"],
    data["source latitude (deg)"],
)
gp.GeoDataFrame(data, geometry=points).plot(ax=ax, marker='D',color=my_tiel, markersize=10, edgecolor='white', linewidth=0.5)

# Draw destination points
points = gp.points_from_xy(
    data["destination longitude (deg)"],
    data["destination latitude (deg)"],
)
gp.GeoDataFrame(data, geometry=points).plot(ax=ax, markersize=60, color=my_tiel, edgecolor='white', linewidth=0.5)

legend_elements = [Line2D([0], [0], color='lightseagreen', lw=1, label='Transport route'),
                   Line2D([0], [0], marker='D', color=my_tiel, label='Collection center', markersize=3, linestyle='None'),
                   Line2D([0], [0], marker='o', color=my_tiel, label='Recycling center', markersize=10, linestyle='None')]
ax.legend(handles=legend_elements, frameon=False, bbox_to_anchor=(0.35, 0.25))
Out[109]:
<matplotlib.legend.Legend at 0x14c17a9b0>

Number of plants opened per year¶

In [110]:
year_open = []
location_open = []
latitude_open = []
longitude_open = []
scenario_open = []
In [111]:
for files in files_list:
    for rows in globals()['%s_plants' % (files)][['year', 'location name','opening cost ($)', 'latitude (deg)', 'longitude (deg)']].iterrows():
        if rows[1][2] != 0:
            year_open.append(rows[1][0]) #year
            location_open.append(rows[1][1]) #location
            #rows[1][2] #amount
            latitude_open.append(rows[1][3]) #lat
            longitude_open.append(rows[1][4]) #long
            scenario_open.append(files)
In [112]:
openings = pd.DataFrame({'Opening year':year_open,
                         'Location name':location_open, 
                         'latitude (deg)':latitude_open, 
                         'longitude (deg)':longitude_open,
                         'Scenario':scenario_open})
In [113]:
files_list
Out[113]:
['Manufacturing_NAICS_0001',
 'Manufacturing_NAICS_05',
 'Manufacturing_NAICS_1',
 'Manufacturing_NAICS_2',
 'Manufacturing_40209_0001',
 'Manufacturing_40209_05',
 'Manufacturing_40209_1',
 'Manufacturing_40209_2',
 'Recycling_NAICS_05',
 'Recycling_NAICS_1',
 'Recycling_NAICS_2',
 'Recycling_NAICS_5',
 'Recycling_NAICS_10',
 'Recycling_40209_05',
 'Recycling_40209_1',
 'Recycling_40209_2',
 'Recycling_40209_5',
 'Recycling_40209_10',
 'Manufacturing_cap_NAICS_05',
 'Manufacturing_cap_NAICS_1',
 'Manufacturing_cap_NAICS_2',
 'Manufacturing_cap_40209_05',
 'Manufacturing_cap_40209_1',
 'Manufacturing_cap_40209_2',
 'Recycling_cap_NAICS_05',
 'Recycling_cap_NAICS_1',
 'Recycling_cap_NAICS_2',
 'Recycling_cap_NAICS_5',
 'Recycling_cap_NAICS_10',
 'Recycling_cap_40209_05',
 'Recycling_cap_40209_1',
 'Recycling_cap_40209_2',
 'Recycling_cap_40209_5',
 'Recycling_cap_40209_10']
In [114]:
openings_recycling_cost_40209 = openings[openings['Scenario'].str.match('Recycling_40209')]
openings_recycling_cost_NAICS = openings[openings['Scenario'].str.match('Recycling_NAICS')]
openings_recycling_cap_40209 = openings[openings['Scenario'].str.match('Recycling_cap_40209')]
openings_recycling_cap_NAICS = openings[openings['Scenario'].str.match('Recycling_cap_NAICS')]

openings_manufacturing_cost_40209 = openings[openings['Scenario'].str.match('Manufacturing_40209')]
openings_manufacturing_cost_NAICS = openings[openings['Scenario'].str.match('Manufacturing_NAICS')]
openings_manufacturing_cap_40209 = openings[openings['Scenario'].str.match('Manufacturing_cap_40209')]
openings_manufacturing_cap_NAICS = openings[openings['Scenario'].str.match('Manufacturing_cap_NAICS')]

40209 Recycling - Cost Analysis¶

In [115]:
openings_recycling_cost_40209
Out[115]:
Opening year Location name latitude (deg) longitude (deg) Scenario
1071 2025 Glen Lyn, Virginia 37.318072 -80.698321 Recycling_40209_05
1072 2040 H B Robinson, South Carolina 34.332185 -79.962115 Recycling_40209_05
1073 2028 San Juan, New Mexico 36.511624 -108.324578 Recycling_40209_05
1074 2043 St Johns River Power Park, Florida 30.335245 -81.648113 Recycling_40209_05
1075 2027 Lansing Smith, Florida 30.238218 -85.631680 Recycling_40209_05
... ... ... ... ... ...
1477 2032 Chesterfield, Virginia 37.378434 -77.585847 Recycling_40209_10
1478 2043 Jefferies, South Carolina 33.207700 -79.953655 Recycling_40209_10
1479 2034 Henderson I, Kentucky 37.792542 -87.572577 Recycling_40209_10
1480 2034 Vanderbilt University Power Plant, Tennessee 36.169129 -86.784790 Recycling_40209_10
1481 2048 Unifi Kinston LLC, North Carolina 35.240068 -77.635510 Recycling_40209_10

411 rows × 5 columns

In [116]:
plt.subplots(figsize=(12,6), dpi=300)
fig = sns.countplot(data=openings_recycling_cost_40209, x="Opening year", hue="Scenario", width=1)

hatches = itertools.cycle(['////', '\\\\', '.O.O', '---', '...'])   
for bars, hatch in zip(fig.containers, hatches):
    # Set a different hatch for each group of bars
    for bar in bars:
        bar.set_hatch(hatch)

fig.set(title='40209 Recycling - Cost Analysis', ylabel="Number of plants opening per year", ylim = (0, 46))
fig.margins(x=0.005)
plt.xticks(rotation=45);
plt.tick_params(
    axis='x',          # changes apply to the x-axis
    which='both',      # both major and minor ticks are affected
    bottom=False,      # ticks along the bottom edge are off
    top=False,         # ticks along the top edge are off
    labelbottom=True) # labels along the bottom edge are off
plt.legend(['0.5', '1', '2', '5', '10'], loc='upper right', frameon=False)
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cost_40209.png'), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cost_40209.pdf'), dpi=300);

40209 Recycling - Capacity Analysis¶

In [117]:
years_list_cat = years_list.astype('str')
years_list_cat
Out[117]:
array(['2025', '2030', '2035', '2040', '2045', '2050'], dtype='<U21')
In [ ]:
 
In [118]:
plt.subplots(figsize=(12,6), dpi=300)
fig = sns.countplot(data=openings_recycling_cap_40209, x="Opening year", hue="Scenario", width=1)

hatches = itertools.cycle(['////', '\\\\', '.O.O', '---', '...'])   
for bars, hatch in zip(fig.containers, hatches):
    # Set a different hatch for each group of bars
    for bar in bars:
        bar.set_hatch(hatch)

fig.set(title='40209 Recycling - Capacity Analysis', ylabel="Number of plants opening per year", ylim = (0, 46))
fig.margins(x=0.005)
plt.xticks(years_list_cat, rotation=45);
plt.tick_params(
    axis='x',          # changes apply to the x-axis
    which='both',      # both major and minor ticks are affected
    bottom=False,      # ticks along the bottom edge are off
    top=False,         # ticks along the top edge are off
    labelbottom=True) # labels along the bottom edge are off
plt.legend(['0.5', '1', '2', '5', '10'], loc='upper right', frameon=False)
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cap_40209.png'), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cap_40209.pdf'), dpi=300);
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/axis.py:1506, in Axis.convert_units(self, x)
   1505 try:
-> 1506     ret = self.converter.convert(x, self.units, self)
   1507 except Exception as e:

File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/category.py:49, in StrCategoryConverter.convert(value, unit, axis)
     48 if unit is None:
---> 49     raise ValueError(
     50         'Missing category information for StrCategoryConverter; '
     51         'this might be caused by unintendedly mixing categorical and '
     52         'numeric data')
     53 StrCategoryConverter._validate_unit(unit)

ValueError: Missing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric data

The above exception was the direct cause of the following exception:

ConversionError                           Traceback (most recent call last)
Cell In [118], line 12
     10 fig.set(title='40209 Recycling - Capacity Analysis', ylabel="Number of plants opening per year", ylim = (0, 46))
     11 fig.margins(x=0.005)
---> 12 plt.xticks(years_list_cat, rotation=45);
     13 plt.tick_params(
     14     axis='x',          # changes apply to the x-axis
     15     which='both',      # both major and minor ticks are affected
     16     bottom=False,      # ticks along the bottom edge are off
     17     top=False,         # ticks along the top edge are off
     18     labelbottom=True) # labels along the bottom edge are off
     19 plt.legend(['0.5', '1', '2', '5', '10'], loc='upper right', frameon=False)

File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/pyplot.py:1809, in xticks(ticks, labels, **kwargs)
   1806         raise TypeError("xticks(): Parameter 'labels' can't be set "
   1807                         "without setting 'ticks'")
   1808 else:
-> 1809     locs = ax.set_xticks(ticks)
   1811 if labels is None:
   1812     labels = ax.get_xticklabels()

File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/axes/_base.py:75, in _axis_method_wrapper.__set_name__.<locals>.wrapper(self, *args, **kwargs)
     74 def wrapper(self, *args, **kwargs):
---> 75     return get_method(self)(*args, **kwargs)

File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/axis.py:1855, in Axis.set_ticks(self, ticks, labels, minor, **kwargs)
   1829 def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs):
   1830     """
   1831     Set this Axis' tick locations and optionally labels.
   1832 
   (...)
   1853     ticks.
   1854     """
-> 1855     result = self._set_tick_locations(ticks, minor=minor)
   1856     if labels is not None:
   1857         self.set_ticklabels(labels, minor=minor, **kwargs)

File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/axis.py:1804, in Axis._set_tick_locations(self, ticks, minor)
   1800 def _set_tick_locations(self, ticks, *, minor=False):
   1801     # see docstring of set_ticks
   1802 
   1803     # XXX if the user changes units, the information will be lost here
-> 1804     ticks = self.convert_units(ticks)
   1805     for name, axis in self.axes._get_axis_map().items():
   1806         if self is axis:

File ~/miniconda3/envs/RELOG/lib/python3.10/site-packages/matplotlib/axis.py:1508, in Axis.convert_units(self, x)
   1506     ret = self.converter.convert(x, self.units, self)
   1507 except Exception as e:
-> 1508     raise munits.ConversionError('Failed to convert value(s) to axis '
   1509                                  f'units: {x!r}') from e
   1510 return ret

ConversionError: Failed to convert value(s) to axis units: array(['2025', '2030', '2035', '2040', '2045', '2050'], dtype='<U21')

NAICS Recycling - Cost Analysis¶

In [ ]:
plt.subplots(figsize=(12,6), dpi=300)
fig = sns.countplot(data=openings_recycling_cost_NAICS, x="Opening year", hue="Scenario", width=1)

hatches = itertools.cycle(['////', '\\\\', '.O.O', '---', '...'])   
for bars, hatch in zip(fig.containers, hatches):
    # Set a different hatch for each group of bars
    for bar in bars:
        bar.set_hatch(hatch)

fig.set(title='NAICS Recycling - Cost Analysis', ylabel="Number of plants opening per year", ylim = (0, 46))
fig.margins(x=0.005)
plt.xticks(rotation=45);
plt.tick_params(
    axis='x',          # changes apply to the x-axis
    which='both',      # both major and minor ticks are affected
    bottom=False,      # ticks along the bottom edge are off
    top=False,         # ticks along the top edge are off
    labelbottom=True) # labels along the bottom edge are off
plt.legend(['0.5', '1', '2', '5', '10'], loc='upper right', frameon=False)
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cost_NAICS.png'), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cost_NAICS.pdf'), dpi=300);

NAICS Recycling - Capacity Analysis¶

In [ ]:
plt.subplots(figsize=(12,6), dpi=300)
fig = sns.countplot(data=openings_recycling_cap_NAICS, x="Opening year", hue="Scenario", width=1)
fig.set(title='NAICS Recycling - Capacity Analysis', ylabel="Number of plants opening per year", ylim = (0, 46))

hatches = itertools.cycle(['////', '\\\\', '.O.O', '---', '...'])   

fig.margins(x=0.005)
for bars, hatch in zip(fig.containers, hatches):
    # Set a different hatch for each group of bars
    for bar in bars:
        bar.set_hatch(hatch)
    
plt.xticks(rotation=45);
plt.tick_params(
    axis='x',          # changes apply to the x-axis
    which='both',      # both major and minor ticks are affected
    bottom=False,      # ticks along the bottom edge are off
    top=False,         # ticks along the top edge are off
    labelbottom=True) # labels along the bottom edge are off
plt.legend(['0.5', '1', '2', '5', '10'], loc='upper right', frameon=False)
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cap_NAICS.png'), transparent=True, dpi=300);
plt.savefig(os.path.join(cwd, 'openings_26_years', 'openings_recycling_cap_NAICS.pdf'), dpi=300);
In [ ]:
 
In [ ]: